let ajaxNum=0;

export  const request = (pramas) =>{
    ajaxNum++;
    wx.showLoading({
      title: '加载中...',
      mask: true
    })
    return new Promise((resolve,reject) => {
        let baseUrl = "https://api-hmugo-web.itheima.net/api/public/v1"
        wx.request({
            ...pramas,
            url: baseUrl + pramas.url,
            success: (result) => {
                resolve(result)
            },
            fail: (err) => {
                reject(err)
            },
            complete:() => {
                ajaxNum--;
                if(ajaxNum === 0){
                    wx.hideLoading()
                }
            }
        });
          
    })
}